#pragma once
#include <osgViewer/api/Win32/GraphicsWindowWin32>
#include <osg\GraphicsContext>
#include <osgViewer/Viewer>
#include <gl\GL.h>
#ifdef _DEBUG
#pragma comment(lib, "osgViewerd.lib")
#pragma comment(lib, "osgd.lib")
#else
#pragma comment(lib, "osgViewer.lib")
#pragma comment(lib, "osg.lib")
#endif
#pragma comment(lib, "Opengl32.lib")


class COSGViewer
{
public:
	void Attach(HWND hWnd); 
	void Detach();
	void SetSceneData(osg::ref_ptr<osg::Group> root);
	COSGViewer(void);
	~COSGViewer(void);
private:
	osgViewer::Viewer m_glViewer;
	osg::ref_ptr<osg::Referenced> m_glWinData;
	osg::ref_ptr<osg::GraphicsContext::Traits> m_glTraits;
	osg::ref_ptr<osg::GraphicsContext> m_glGC;
	osg::ref_ptr<osg::Camera> m_glCamera;
	HWND m_hCurrentWnd;

	////------helper functions----////
	void Init(HWND hWnd);
	void StartViewer();
	static UINT StartViewerAdapter(LPVOID viewer);
	void RunViewer();
	CWinThread* m_thdCurrent; 
};
